mui.init({
	pullRefresh: {
		container: "#refreshContainer", //下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
		down: {
			style: 'circle', //必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
			color: '#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
			height: '50px', //可选,默认50px.下拉刷新控件的高度,
			range: '100px', //可选 默认100px,控件可下拉拖拽的范围
			offset: '0px', //可选 默认0px,下拉刷新控件的起始位置
			auto: false, //可选,默认false.首次加载自动上拉刷新一次
			callback: function () {
                kefuDataList.getKefuData();
                setTimeout(function() {
                    mui("#refreshContainer").pullRefresh().endPulldownToRefresh(false);
                },1000);
            }
		}
	},
});

var kefuDataList;
mui.plusReady(function () {
    kefuDataList = new Vue({
        el: '#list_box',
        data: {
            lists: '',
        },
        mounted() {
            this.getKefuData();
        },
        methods: {
            getKefuData: function () {
            	showWatting();
                var api_host = plus.storage.getItem('HOST_URL');
				var self=this;
                mui.ajax({
                    url: api_host + '/api/cusservice/cusservice/cuslist',
                    dataType: 'json',
					headers:{'User-Token':plus.storage.getItem('UserToken')},
                    type: 'get',
                    success: function (msg) {
                        self.lists = msg.data;
                    },
                    error: function () {
                        console.log('获取客服列表出错');
                    },
                    complete:function() {
                    	plus.nativeUI.closeWaiting();
                    }
                })
            },
            open_details:function (id,status) {
                mui.openWindow({
                    url: 'consultantDetail.html',
                    createNew:false,
                    extras:{
                        'kid':id,
                        'status':status
                    },
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                    	autoShow: false,
                    }
                })
            }
        }
    })
})

window.addEventListener('dataList', function(event){
    kefuDataList.getKefuData();
})
